import 'package:flutter/material.dart';
import 'package:get/get.dart';

import '../../RouteConfig/Route.dart';



class ATestDialogPage extends StatelessWidget {
  ATestDialogPage({super.key});
  var _routes = [];
  @override
  Widget build(BuildContext context) {
    _routes = Routes.where((route) {
     return  route.name.startsWith('/ATest7Page/ATestDialogPage/');
    }).toList();
    return Scaffold(
      appBar: AppBar(
        title: const Text('测试对话框'),
      ),
      body:
          ListView(children: _routes.map((route) => ElevatedButton(child: Text(route.name),onPressed: ()async {
            //弹出对话框并等待其关闭
            bool? delete = await showDeleteConfirmDialog1(context);
            if (delete == null) {
              print("取消删除");
            } else {
              print("已确认删除");
              //... 删除文件
            }
          })).toList()),
    );
  }
}



// 弹出对话框
Future<bool?> showDeleteConfirmDialog1(BuildContext context) {
  return showDialog<bool>(
    context: context,
    builder: (context) {
      return AlertDialog(
        title: Text("提示"),
        content: Text("您确定要删除当前文件吗?"),
        actions: <Widget>[
          TextButton(
            child: Text("取消"),
            onPressed: () => Navigator.of(context).pop(), // 关闭对话框
          ),
          TextButton(
            child: Text("删除"),
            onPressed: () {
              //关闭对话框并返回true
              Navigator.of(context).pop(true);
            },
          ),
        ],
      );
    },
  );
}